<?php
/**
 * Joomla! 1.5 component JoomGPSTracks
 *
 * @version $Id: joomgpstracks.php 2009-06-24 15:40:19 svn $
 * @author Michael Pfister
 * @package joomGPStracks
 * @subpackage frontend
 * @license GNU/GPL
 * @filesource
 *
 * 
 */

// no direct access
defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.model');

/**
 * JoomGPSTracks Component JoomGPSTracks Model
 *
 * @author      notwebdesign
 * @package		Joomla
 * @subpackage	JoomGPSTracks
 * @since 1.5
 */
class JoomgpstracksModelJoomgpstracks extends JModel {
    /**
	 * Constructor
	 */
	function __construct() {

		parent::__construct();
    }

    function getTracksData($order, $limit)  {
        global $mainframe;

        $db =& JFactory::getDBO();

        $query = "SELECT a.*, b.title AS cat FROM #__gps_tracks AS a"
                . "\n LEFT JOIN #__gps_cats AS b"
                . "\n ON a.catid=b.id"
                . "\n" . $order
                . "\n" . $limit;

        $db->setQuery($query);
        $rows = $db->loadObjectList();

        return $rows;
    }

    function getCatsData()  {
        global $mainframe;

        $db =& JFactory::getDBO();

        $query = "SELECT * FROM #__gps_cats"
                . "\n ORDER BY title ASC";

        $db->setQuery($query);
        $rows = $db->loadObjectList();

        return $rows;
    }
}
?>